#!/usr/bin/env node
var Wiktionary  = require('./src/wiktionary').Wiktionary;


var usage =  "Usage: 'node execute <options>'\n"
            +"  options:\n"
            +"  [-o|--output] : Optional (default: './out')\n"
            +"                  The folder for the results.\n"
            +"  [-i|--input]  : Mandatory. A folder with input data in it, the expected contents:\n"
            +"                  - (optional) '*.tsv' - a wiktionary dump of some kind (e.g.: one downloaded and unzipped from \n"
            +"                    http://toolserver.org/~enwikt/definitions/)\n"
            +"                  - (mandatory) a 'languages' folder with one or more sub-folders named after languages in the tsv file\n"
            +"                    (e.g.: 'Italian'). Each such folder has to contain a 'sample.txt' file\n"
            +"                    (e.g.: a utf-8 book or books in the given language) used for frequency sampling and subsequently\n"
            +"                    ranking the output (ordering its dictionary entries).\n"


var argv = require('optimist')
    .default('o', "./out")
    .demand(['i'])
    .usage(usage)
    .argv;

var wiktionary = new Wiktionary({
    url         : "http://toolserver.org/~enwikt/definitions/enwikt-defs-20100326-all.tsv.gz",
    output      : argv.o,
    input       : argv.i,
    scratch     : "./.scratch"
}).formalise().otherwise(function(err){
    console.log(err.stack);
});
